package Binrary_Management_System.ioPeration;

import Binrary_Management_System.Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-09-13
 * Time: 14:03
 */
public class FindOpertion implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        int currentSize = bookList.getUseSize();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找的书的书名：");
        String name = scanner.nextLine();
        int i = 0;
        for (; i < currentSize; i++) {
            if(bookList.getBook(i).getName().equals(name)) {
                System.out.println("找到了你要找的书：");
                System.out.println(bookList.getBook(i));
                return;
            }
        }
        if(i == currentSize) {
            System.out.println("没有你要找的书！");
            return;
        }
    }
}
